module multibits_chk_onehot #(
parameter WIDTH=16
)(
input [WIDTH-1:0] din         ,
output            ois_onehot  
);

wire [WIDTH-1:0]mask_high;
genvar i;
// just like gray code to bin code
generate
for(i = 0; i< WIDTH; i = i +1)begin:HIGH
  if( i== 0 )
    assign mask_high[i] = din[i];
  else
    assign mask_high[i] = din[i] ^ mask_high[i-1];
end
endgenerate

wire is_onehot = mask_high[WIDTH-1] & (&(mask_high[WIDTH-2:0] | ~din[WIDTH-2:0]));
wire is_mass = ~&(mask_high | ~din);

assign ois_onehot = is_onehot;

endmodule

